package biz.ezcom.s2sh.dao.impl;

import java.util.List;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import biz.ezcom.s2sh.dao.UserDao;
import biz.ezcom.s2sh.pojo.User;

public class UserDaoImpl extends HibernateDaoSupport implements UserDao {

	@Override
	public void saveUser(User user) {
		this.getHibernateTemplate().save(user);
	}
	@SuppressWarnings("unchecked")
	@Override
	public List<User> findAllUsers() {
		String hql = "from User user order by user.id desc";
		return (List<User>)this.getHibernateTemplate().find(hql);
	}
	@Override
	public void removeUser(User user) {
		this.getHibernateTemplate().delete(user);
	}
	@Override
	public void update(User user) {
		this.getHibernateTemplate().update(user);
	}
	@Override
	public User findUserById(int id) {
		return (User) this.getHibernateTemplate().get(User.class, id);
	}
	

}
